/*
    公共头文件，包含一些公共变量的定义
    建议和go语言的定义保持一致
*/

#ifndef PUB_H_
#define PUB_H_

// cpp 和 c 兼容性，打开
#ifdef __cplusplus
extern "C" {
#endif

// 从 stdint.h 参考了一部分实现

/* Signed. */

/* There is some amount of overlap with <sys/types.h> as known by inet code */
typedef signed char int8;
typedef short int   int16;
typedef int         int32;
#if __WORDSIZE == 64
typedef long int int64;
#else
__extension__ typedef long long int          int64;
#endif

/* Unsigned. */
typedef unsigned char      uint8;
typedef unsigned short int uint16;
#ifndef __uint32_t_defined
typedef unsigned int uint32;
#define __uint32_t_defined
#endif
#if __WORDSIZE == 64
typedef unsigned long int uint64;
#else
__extension__ typedef unsigned long long int uint64;
#endif

/* Types for `void *' pointers. */
#if __WORDSIZE == 64
#ifndef __intptr_defined
typedef long int intptr;
#define __intptr_defined
#endif
typedef unsigned long int uintptr;
#else
#ifndef __intptr_defined
typedef int                                  intptr;
#define __intptr_defined
#endif
typedef unsigned int                         uintptr;
#endif

typedef enum _bool {
    true  = 0,
    false = 1,
} bool;

// 自定义

// typedef enum {
//     true = 0,
//     false
// }bool;

// typedef int BOOL;
// #define true 0
// #define false 1

#ifdef __cplusplus
}
#endif

#endif // PUB_H
